#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using Neatly.UI;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.UI;

namespace NeatlyEditor.UI
{
    [CustomEditor(typeof(NCheckBox), true)]
    [CanEditMultipleObjects]
    public class NCheckBoxEditor : Editor
    {
        #region SerializedProperty
        SerializedProperty m_InteractableProperty;
        SerializedProperty m_SetCheckBoxCrossImgProperty;
        #endregion

        #region GUIContent
        GUIContent m_SetCheckBoxContent;
        #endregion

        readonly AnimBool m_ShowCheckImg = new AnimBool();

        protected virtual void OnEnable()
        {
            m_InteractableProperty = serializedObject.FindProperty("m_Interactable");
            m_SetCheckBoxCrossImgProperty = serializedObject.FindProperty("m_ImgCross");

            m_SetCheckBoxContent = new GUIContent("复选框图片");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_InteractableProperty);
            ++EditorGUI.indentLevel;
            if (m_InteractableProperty.boolValue)
            {
                EditorGUILayout.PropertyField(m_SetCheckBoxCrossImgProperty, m_SetCheckBoxContent);
                var crossGraphic = m_SetCheckBoxCrossImgProperty.objectReferenceValue as Graphic;
                if (crossGraphic == null)
                    EditorGUILayout.HelpBox("为空没视觉效果，但是值有效果", MessageType.Info);
            }
            --EditorGUI.indentLevel;
            serializedObject.ApplyModifiedProperties();
        }

    }
}
